package com.thrsdk.ui.dialog;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.thrsdk.constants.AppConfig;
import com.thrsdk.listener.SDKListenerInfo;
import com.thrsdk.model.data.PayInfo;

public class PayDialog extends Dialog {
    private Context mContext;
    private View mView;
    private SDKListenerInfo listener;
    private Button mLogin;
    private PayInfo paymentInfo;

    public PayDialog(Context context, PayInfo paymentInfo, SDKListenerInfo listener) {
        super(context, AppConfig.resourceId(context,
                "thf_MyDialog", "style"));
        // TODO Auto-generated constructor stub
        this.mContext = context;
        this.listener = listener;
        this.paymentInfo = paymentInfo;
        this.mView = LayoutInflater.from(context).inflate(
                AppConfig.resourceId(context, "thf_pay_dialog", "layout"),
                null);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(mView);
        mLogin = (Button) findViewById(AppConfig.resourceId(mContext, "dialog_pay", "id"));
        ((TextView) findViewById(AppConfig.resourceId(mContext, "pay_orderid", "id"))).setText("订单号：" + paymentInfo.getOrderid());
        ((TextView) findViewById(AppConfig.resourceId(mContext, "pay_amount", "id"))).setText("金额/分：" + paymentInfo.getAmount());
        ((TextView) findViewById(AppConfig.resourceId(mContext, "pay_dec", "id"))).setText("商品描述：" + paymentInfo.getProductName());
        mLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (null != mPayInterface) {
                    mPayInterface.clickPay();

                }

            }
        });
        this.setCancelable(false);
        this.setCanceledOnTouchOutside(false);
    }

    public PayInterface mPayInterface;

    public interface PayInterface {
        void clickPay();
    }

    public void setmPayInterface(PayInterface mPayInterface) {
        this.mPayInterface = mPayInterface;
    }
}
